<template>
  <div class="cloud">
    <h2 class="hometitle>">标签云</h2>
    <ul>
      <a v-for="item in hotTagData" :key="item.uid" href="javascript:void(0);">{{item.content}}</a>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      hotTagData: [
        // {
        //   uid: 1,
        //   content: "Java"
        // },
        // {
        //   uid: 2,
        //   content: "SpringBoot"
        // },
        // {
        //   uid: 3,
        //   content: "Vue"
        // },
        // {
        //   uid: 4,
        //   content: "面试"
        // },
        // {
        //   uid: 5,
        //   content: "mysql"
        // }
      ] //标签列表
    };
  },
  mounted() {
    let session = window.localStorage;
    let blogs = JSON.parse(session.getItem("blogs"));
    for (let i = 0; i < blogs.length; i++) {
      let tags = blogs[i].tags;
      for (let j = 0; j < tags.length; j++) {
        let uid = this.hotTagData.length + 1;
        let flag = true;
        for (let x = 0; x < this.hotTagData.length; x++) {
          if (this.hotTagData[x].content == tags[j]) {
            flag = false;
            break;
          }
        }
        if (flag) {
          this.hotTagData.push({
            uid,
            content: tags[j]
          });
        }
      }
    }
  }
};
</script>

<style>
</style>